package com.hz.house.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hz.house.bean.entity.*;
import com.hz.house.bean.es.SellManEsDocumentBean;
import com.hz.house.bean.vo.SellManCachedBasicInfoBean;
import com.hz.house.bean.vo.SellManDynamicVo;
import com.hz.house.common.ResultBean;
import com.hz.house.common.ResultUtil;
import com.hz.house.dao.SellManMapper;
import com.hz.house.dao.SellManMapperExt;
import com.hz.house.enums.*;
import com.hz.house.enums.building.SellStateEnum;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;


/**
 * 置业顾问
 */
@Service
public class SellManServiceExt {

    @Resource
    private SellManMapperExt sellManMapperExt;
    @Resource
    private SellManMapper sellManMapper;
    @Autowired
    private RedisTemplate<String, Object> redis;
    @Autowired
    private RedisCacheDataService cacheService;

    @Autowired
    private SellManService sellManService;

    @Resource
    private RestTemplate ribbonTemplate;

    private final String BUILDING_SERVICE_URL = "http://house-small-building/ms/building";

    public static final String SELLMAN_DYNAMIC = "bbs_sellman_dynamic_list_page";


    /**
     * 置业顾问发布动态
     *
     * @param content
     * @param imgs
     * @param currentUserId
     */
    public ResultBean releaseDynamic(String content, List<String> imgs, Integer currentUserId) {
        if (StringUtils.isEmpty(content) && (imgs == null || imgs.size() == 0))
            return ResultUtil.fail("请填写内容或上传图片的任意一种");
        if (!StringUtils.isEmpty(content) && content.length() > 1000)
            return ResultUtil.fail("发表内容过长");
        //检查内容是否违规
        if (!checkContent(content))
            return ResultUtil.fail("动态内容包含敏感文字!");
        SellManDynamic dyn = new SellManDynamic();
        dyn.setCustomerId(currentUserId);
        String imgStr = "";
        if (imgs != null && imgs.size() > 0) {
            for (String i : imgs)
                imgStr += i + ",";
            dyn.setImgStr(imgStr.substring(0, imgStr.lastIndexOf(",")));
        }
        dyn.setContent(content);
        dyn.setCreateTime(new Date());
        sellManMapperExt.releaseDynamic(dyn);
        redis.delete(SELLMAN_DYNAMIC);
        return ResultUtil.ok();
    }


    private boolean checkContent(String content) {
        //ribbonTemplate
        String url = this.BUILDING_SERVICE_URL + "/checkTextContent";
        String res = this.doPostSendMsg(content, url);
        System.out.println(res);
        JSONObject jo = JSON.parseObject(res);
        if (jo.getIntValue("code") != 200)
            return false;
        return jo.getBooleanValue("data");

    }


    /**
     * 封装http请求发送post,返回接口的结果
     */
    private String doPostSendMsg(String jsonData, String url) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity<String> entity = new HttpEntity<String>(jsonData, headers);
        String json = ribbonTemplate.postForObject(url, entity, String.class);
        return json;
    }

    /**
     * 查询置业顾问动态列表
     *
     * @return
     */
    public ResultBean queryDynamic(Integer customerId, Integer page) {
        if (page == null || page < 1)
            page = 1;
        SellManDynamicVo dyn = sellManMapperExt.queryDynamic(customerId, (page - 1) * 10);
        if (dyn == null)
            return ResultUtil.fail("获取置业顾问信息失败");

        SellStateEnum enu = SellStateEnum.getStateById(dyn.getSellStatus());
        if (enu != null)
            dyn.setShowStatus(enu.getName());
        else
            dyn.setShowStatus("暂无");
        List<SellManDynamic> ds = dyn.getDyns();
        if (ds != null && ds.size() > 0) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            for (SellManDynamic dy : ds) {
                dy.setCustomerId(dyn.getCustomerId());
                dy.setBuildingId(dyn.getBuildingId());
                dy.setBuildingName(dyn.getBuildingName());
                dy.setImgs(getImgList(dy.getImgStr()));
                dy.setImgStr(null);
                dy.setShowTime(sdf.format(dy.getCreateTime()));
                dy.setCreateTime(null);
            }
        }
        Integer total = sellManMapperExt.getTotal(customerId);
        Map<String, Object> m = new HashMap<>();
        m.put("person", dyn);
        m.put("total", total);
        return ResultUtil.ok(m);
    }

    private List<String> getImgList(String imgStr) {
        if (StringUtils.isEmpty(imgStr))
            return new ArrayList<>();
        return Arrays.asList(imgStr.split(","));
    }

    /**
     * 删除置业顾问动态
     *
     * @param id
     * @param customerId
     */
    public ResultBean delDynamic(Integer id, Integer customerId) {
        sellManMapperExt.delDynamic(id, customerId);
        redis.delete(SELLMAN_DYNAMIC);
        return ResultUtil.ok();
    }

    /**
     * 置业顾问申请或修改
     *
     * @param pc
     */
    public ResultBean modifySellMan(SellManBasicInfo pc) {
        if (StringUtils.isEmpty(pc.getName())) {
            return ResultUtil.fail("请填写名字");
        }
        String phone = pc.getPhone();
        if (StringUtils.isEmpty(phone)) {
            return ResultUtil.fail("请输入手机号");
        }
        String smsCode = pc.getSmsCode();
        if (StringUtils.isEmpty(smsCode)) {
            return ResultUtil.fail("请填写验证码");
        }
        if (StringUtils.isEmpty(pc.getWx())) {
            return ResultUtil.fail("请填写微信号");
        }
        if (StringUtils.isEmpty(pc.getBuildingName())) {
            return ResultUtil.fail("无当前主楼盘信息");
        }
        if (pc.getBuildingId() == null) {
            return ResultUtil.fail("无当前主楼盘信息");
        }
//        if (Objects.isNull(pc.getTwoBuildingId())) {
//            return ResultUtil.fail("无当前副楼盘信息");
//        }
//        if (StringUtils.isEmpty(pc.getTwoBuildingName())) {
//            return ResultUtil.fail("无当前副楼盘信息");
//        }
        if (StringUtils.isEmpty(pc.getWxQrcode())) {
            return ResultUtil.fail("请上传微信二维码");
        }
        if (StringUtils.isEmpty(pc.getWorkCard())) {
            return ResultUtil.fail("请上传工牌");
        }
        String rcode = (String) redis.opsForValue().get(phone);
        if (!smsCode.equals(rcode)) {
            return ResultUtil.fail("当前验证码已过期或有误，请重新输入");
        }
        SellManCachedBasicInfoBean basic = cacheService.getSellManBasicInfo(pc.getCustomerId());
        if (basic == null) {
            //新增
            pc.setState(SellManStateEnum.apply.name());
            pc.setCreateDate(new Date());
            // 设置邀请者id
            if (!StringUtils.isEmpty(pc.getInvitePhone())) {
                pc.setInviteId(sellManMapperExt.getInviteId(pc.getInvitePhone()));
            }
        } else {
            // 修改
            pc.setState(SellManStateEnum.update.name());
            pc.setUpdateDate(new Date());
            //删除楼盘详情得原来得缓存
            int buildingId = basic.getBuildingId();
            this.redis.delete("house:building:detail:" + buildingId);
        }
        sellManMapperExt.modifySellMan(pc);
        return ResultUtil.ok();
    }

    public ResultBean exchangeBuilding(Integer customerId) {
        SellManBasicInfo sellManBasicInfo = sellManMapperExt.getBasicInfo(customerId);
        if (ObjectUtils.isEmpty(sellManBasicInfo)){
			return ResultUtil.fail("当前用户不是置业顾问");
		}
        sellManMapper.exchangeBuilding(sellManBasicInfo.getBuildingId(), sellManBasicInfo.getTwoBuildingId(), customerId);
        return ResultUtil.ok("主营楼盘切换成功");
    }

    public ResultBean getBuildingByName(String name) {
        if (StringUtils.isEmpty(name)) {
            return ResultUtil.fail("请输入楼盘名称");
        }
        return ResultUtil.ok(sellManMapperExt.getBuildingByName(name));
    }

    /**
     * 获取置业顾问基本信息
     *
     * @param currentUserId
     * @return
     */
    public ResultBean getBasicInfo(Integer currentUserId) {
        return ResultUtil.ok(sellManMapperExt.getBasicInfo(currentUserId));
    }

    /**
     * 用户签到
     *
     * @param customerId
     * @return
     */
    @Transactional
    public ResultBean sign(Integer customerId) {
        Date now = new Date();
        // 获取当前用户最后一次签到时间及总经验
        Map<String, Object> m = sellManMapperExt.findLastSign(customerId);
        UserSign sign = new UserSign();
        Integer totalExp = 0;
        if (m != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String lastStr = sdf.format((Date) m.get("lastSignDate"));
            if (sdf.format(now).equals(lastStr))
                return ResultUtil.fail("今日已签到");
            // 判断用户是否连续签到
            String bef = getBeforeStr();
            if (bef.equals(lastStr))
                sign.setSeries(true); // 连续签到
            // 处理等级
            totalExp = (Integer) m.get("exp") + 10;
        }
        // 设置最近活跃时间、签到增加的经验
        sign.setCustomerId(customerId);
        sign.setLastActivity(now);
        sign.setExp(ExperienceTypeEnum.sign.getXpValue());
        sign.setLevel(getLevel(totalExp));
        // 更新用户表总经验、连续签到次数、最近活动时间、等级
        sellManMapperExt.modifyXp(sign);
        // 新增经验记录表
        addExpRecode(customerId, ExperienceTypeEnum.sign, "恭喜你！签到成功", now);
        // 增加签到记录
        addSignRecode(customerId, now);
        return ResultUtil.ok();
    }

    /**
     * 处理用户等级
     *
     * @param xp
     * @return
     */
    private Integer getLevel(Integer xp) {
        Integer level = 0;
        if (xp >= 0 && xp <= CustomerLevelEnum.one.getXp())
            level = CustomerLevelEnum.one.getLevel();
        if (xp >= CustomerLevelEnum.one.getXp() && xp <= CustomerLevelEnum.two.getXp())
            level = CustomerLevelEnum.two.getLevel();
        if (xp >= CustomerLevelEnum.two.getXp() && xp <= CustomerLevelEnum.three.getXp())
            level = CustomerLevelEnum.three.getLevel();
        if (xp >= CustomerLevelEnum.three.getXp() && xp <= CustomerLevelEnum.four.getXp())
            level = CustomerLevelEnum.four.getLevel();
        if (xp >= CustomerLevelEnum.four.getXp() && xp <= CustomerLevelEnum.five.getXp())
            level = CustomerLevelEnum.five.getLevel();
        if (xp >= CustomerLevelEnum.five.getXp() && xp <= CustomerLevelEnum.six.getXp())
            level = CustomerLevelEnum.six.getLevel();
        if (xp >= CustomerLevelEnum.six.getXp()) {
            level = CustomerLevelEnum.seven.getLevel();
        }
        return level;
    }

    /**
     * 增加签到记录
     *
     * @param customerId
     */
    private void addSignRecode(Integer customerId, Date now) {
        LocalDate date = LocalDate.now();
        UcSignRecode r = new UcSignRecode();
        r.setCustomerId(customerId);
        r.setDay(date.getDayOfMonth());
        r.setMonth(date.getMonthValue());
        r.setYear(date.getYear());
        r.setSignDate(now);
        r.setCreateDate(now);
        sellManMapperExt.addSignRecode(r);
    }

    /**
     * 添加经验记录
     *
     * @param customerId
     * @param sign
     * @param content
     */
    private void addExpRecode(Integer customerId, ExperienceTypeEnum sign, String content, Date now) {
        UcXpRecode rec = new UcXpRecode();
        rec.setCustomerId(customerId);
        rec.setAction(sign.getAction());
        rec.setContent(content);
        rec.setTargetId(0);
        rec.setTargetType(sign.name());
        rec.setType(sign.name());
        rec.setXpNum(sign.getXpValue());
        rec.setCreateDate(now);
        sellManMapperExt.addExpRecode(rec);
    }

    /**
     * 获取当前时间的前一天
     *
     * @return
     */
    private String getBeforeStr() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.add(Calendar.DATE, -1);
        return sdf.format(c.getTime());
    }

    /**
     * 获取用户签到记录以及是否可以签到
     *
     * @param customerId
     * @param year
     * @param month
     * @return
     */
    public ResultBean getSignInfo(Integer customerId, Integer year, Integer month) {
        LocalDate now = LocalDate.now();
        if (year == null || month == null) {
            year = now.getYear();
            month = now.getMonthValue();
        }
        UserSign sign = new UserSign();
        // 获取当前用户最近、最早一次签到时间及连续签到天数
        Map<String, Object> m = sellManMapperExt.getLastAndNearSignTime(customerId);
        if (m == null) {
            sign.setStartMonth(true);
            sign.setEndMonth(true);
            sign.setSeriesNum(0);
            sign.setRecodeList(new ArrayList<>());
            return ResultUtil.ok(sign);
        }
        Date nearTime = (Date) m.get("nearTime");
        Date farthTime = (Date) m.get("farthTime");
        Integer seriesNum = (Integer) (m.get("seriesSignCount"));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String near = sdf.format(nearTime);
        // 今日是否签到boolean
        boolean todaySign = sdf.format(System.currentTimeMillis()).equals(near);
        // 判断今日是否签到
        if (nearTime != null && todaySign)
            sign.setSignStatus(true);
        // 判断是否连续签到，不是连续签到设置连续签到的天数为0
        String befStr = getBeforeStr();
        if (!befStr.equals(near) && !todaySign)
            seriesNum = 0;
        sign.setSeriesNum(seriesNum);
        //判断是否可以翻页
        sign.setStartMonth(isStart(farthTime, year, month)); // 是否为起始月
        sign.setEndMonth(isEnd(now, year, month));  // 是否为终止月
        // 查询签到记录
        List<UcSignRecode> recs = sellManMapperExt.querySignRecords(customerId, year, month);
        sign.setRecodeList(recs);
        return ResultUtil.ok(sign);
    }

    /**
     * 是否为终止月
     *
     * @param now
     * @param year
     * @param month
     * @return
     */
    private boolean isEnd(LocalDate now, Integer year, Integer month) {
        int yr = now.getYear();
        int mn = now.getMonthValue();
        return year > yr || (year == yr && month >= mn);
    }

    /**
     * 判断是否到起始月
     *
     * @param farth
     * @return
     */
    private boolean isStart(Date farth, Integer year, Integer month) {
        LocalDateTime ft = date2LocalDate(farth);
        int yr = ft.getYear();
        int mn = ft.getMonthValue();
        return (year < yr) || (year == yr && month <= mn);
    }


    private LocalDateTime date2LocalDate(Date date) {
        Instant instant = date.toInstant();
        ZoneId zoneId = ZoneId.systemDefault();
        return instant.atZone(zoneId).toLocalDateTime();
    }

    /**
     * 获取用户系统消息
     *
     * @param customerId
     * @return
     */
    public ResultBean getSystemMsg(Integer customerId, Integer page) {
        if (page == null || page < 1)
            page = 1;
        List<SystemMsg> msgs = sellManMapperExt.getSystemMsg(customerId, (page - 1) * 15);
        if (msgs != null && msgs.size() > 0) {
            Date now = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
            for (SystemMsg msg : msgs) {
                Date createTime = msg.getCreateTime();
                if (sdf.format(now).equals(sdf.format(createTime)))
                    msg.setShowTime(sdf1.format(createTime));
                else
                    msg.setShowTime(sdf.format(createTime));
                msg.setCreateTime(null);
                // 处理页面跳转路径
                SystemMsgEnum enu = SystemMsgEnum.getSystemMsgEnum(msg.getMsgType());
                if (enu != null && enu.getPath() != null)
                    msg.setPath(enu.getPath() + "?" + msg.getParam());
                msg.setParam(null);
            }
        }
        Integer total = sellManMapperExt.getAllMsgNum(customerId);
        Map<String, Object> m = new HashMap<>();
        m.put("total", total);
        m.put("msgs", msgs);
        return ResultUtil.ok(m);
    }

    /**
     * 设置消息已读,不传id设置所有未已读
     *
     * @param id
     * @return
     */
    public ResultBean editMsgRead(Integer customerId, Integer id) {
        sellManMapperExt.editMsgRead(customerId, id);
        return ResultUtil.ok();
    }

    private Map<String, Object> getDateMap() {
        Date now = new Date();
        Calendar cl = Calendar.getInstance();
        cl.add(Calendar.DATE, -30);
        Date preDate = cl.getTime();
        Map<String, Object> m = new HashMap<>();
        m.put("pre", preDate);
        m.put("now", now);
        return m;
    }


    /**
     * 查询置业顾问总积分、活跃度以及今日加分
     *
     * @param customerId
     * @return
     */
    public ResultBean getMyScore(Integer customerId) {
        Map<String, Object> m = getDateMap();
        m.put("customerId", customerId);
        return ResultUtil.ok(sellManMapperExt.getMyScore(m));
    }

    /**
     * 查询我关注的楼盘
     *
     * @param customerId
     * @return
     */
    public ResultBean getMyBuildingFocus(Integer customerId, Integer page) {
        List<Integer> ids = sellManMapperExt.getFocusBuildingId(customerId);
        if (ids == null || ids.size() < 0)
            return ResultUtil.ok();
        if (page == null || page < 1)
            page = 1;
        Map<String, Object> m = this.getBuildingFocus(ids, page);
        return ResultUtil.ok(m);
    }

    /**
     * 查询我关注的置业顾问
     *
     * @param customerId
     * @return
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    public ResultBean getMySellManFocus(Integer customerId, Integer page) {
        List<Integer> ids = sellManMapperExt.getMySellManFocus(customerId);
        if (ids == null || ids.size() < 0)
            return ResultUtil.ok();
        if (page == null || page < 1)
            page = 1;
        BoolQueryBuilder query = QueryBuilders.boolQuery();
        query.must(QueryBuilders.termsQuery("customerId", ids));
        SortBuilder sort = SortBuilders.fieldSort("rank").order(SortOrder.ASC);
        Map<String, Object> res = sellManService.doSearch(query, sort, page, null);
        long total = (long) res.get("total");//总条数
        List<Map<String, Object>> data = (List<Map<String, Object>>) res.get("data");
        List<SellManEsDocumentBean> rows = new ArrayList<>();
        sellManService.buildData(data, rows);
        Map<String, Object> m = new HashMap<>();
        m.put("total", total);
        m.put("rows", rows);
        return ResultUtil.ok(m);
    }

    /**
     * 我的个人中心
     *
     * @param customerId
     * @return
     */
    public ResultBean myCenter(Integer customerId) {
        PersonCenter ct;
        Map<String, Object> m = new HashMap<>();
        if (cacheService.getSellManBasicInfo(customerId) != null) { //置业顾问
            ct = sellManMapperExt.getSellManCenter(customerId);
            m.put("role", "sell_man");
        } else {// 非置业顾问用户
            ct = sellManMapperExt.getUserCenter(customerId);
            m.put("role", "customer");
        }
        if (ct == null)
            return ResultUtil.fail("您的身份状态可能存在异常，请联系官方客服");
        if (ct.getMsgNum() > 0)
            ct.setHasMsg(true);
        m.put("myCenter", ct);
        return ResultUtil.ok(m);
    }

    /**
     * 获取置业顾问个人主页以及关注点赞状态
     *
     * @param currentUserId 当前登录人id
     * @param customerId    主页顾问customerId
     * @return
     */
    @SuppressWarnings("unchecked")
    public ResultBean getSellManHomePage(Integer currentUserId, Integer customerId) {
        if (customerId == null)
            return ResultUtil.fail("无法获取当前置业顾问信息");
        QueryBuilder query = QueryBuilders.termQuery("customerId", customerId);
        Map<String, Object> res = sellManService.doSearch(query, null, 0, null);
        long total = (long) res.get("total");//总条数
        if (total == 0)
            return ResultUtil.fail("无法获取当前置业顾问信息");
        List<Map<String, Object>> data = (List<Map<String, Object>>) res.get("data");
        List<SellManEsDocumentBean> rows = new ArrayList<>();
        sellManService.buildData(data, rows);
        SellManEsDocumentBean esBean = rows.get(0);
        Map<String, Object> m = new HashMap<>();
        // 查询当前用户是否关注以及点赞置业顾问
        SellManCachedBasicInfoBean basic = cacheService.getSellManBasicInfo(currentUserId);
        if (basic != null && currentUserId.intValue() == customerId.intValue()) {
            // 当前登录用户就是置业顾问本人
            m.put("focus", false);
            m.put("prise", sellManService.isTodayPraiseSellMan(currentUserId, customerId));
        } else {
            int focus = sellManMapperExt.getFocus(currentUserId, customerId);
            m.put("focus", focus > 0);
            m.put("prise", sellManService.isTodayPraiseSellMan(currentUserId, customerId));
        }
        m.put("sellManInfo", esBean);
        // 增加浏览量
        sellManService.addSellManVisits(customerId);
        return ResultUtil.ok(m);
    }

    /**
     * 查询置业顾问消费记录
     *
     * @param customerId
     * @param page
     * @return
     */
    public ResultBean queryConsumeRecord(Integer customerId, Integer page) {
        if (page == null || page < 1)
            page = 1;
        List<SellmanScoreConsumeRecord> res = sellManMapperExt.queryConsumeRecord(customerId, (page - 1) * 10);
        if (res != null && res.size() > 0) {
            Date now = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
            for (SellmanScoreConsumeRecord r : res) {
                if (r.getMinusScoreType() == ScoreConsumeTypeEnum.goldcoin.getId()) {
                    r.setShowStr("积分兑换财富币");
                    r.setShowType(1);
                } else {
                    r.setShowStr("积分兑换奖品");
                    r.setShowType(2);
                }
                // 处理展示时间
                Date createTime = r.getCreateTime();
                if (sdf.format(now).equals(sdf.format(createTime)))
                    r.setShowTime(sdf1.format(createTime));
                else
                    r.setShowTime(sdf.format(createTime));
                r.setCreateTime(null);
                r.setMinusScoreType(null);
            }
        }
        int total = sellManMapperExt.getConsumeTotal(customerId);
        Map<String, Object> m = new HashMap<>();
        m.put("res", res);
        m.put("total", total);
        return ResultUtil.ok(m);
    }

    @SuppressWarnings("unchecked")
    private Map<String, Object> getBuildingFocus(List<Integer> ids, Integer page) {
        //ribbonTemplate
        String url = this.BUILDING_SERVICE_URL + "/getMyBuildingFocus";
        BuildingFocusReqBean bf = new BuildingFocusReqBean();
        bf.setIds(ids);
        bf.setPage(page);
        Map<String, Object> m = ribbonTemplate.postForObject(url, bf, Map.class);
        return m;
    }

    public Object getLPR() {
        String defLpr = "4.05,4.75";
        String lpr = this.cacheService.getLpr();
        if (lpr == null)
            return ResultUtil.ok(null, defLpr);
        return ResultUtil.ok(null, lpr);
    }

}
